package pers.xiaojun.boot.module.system.controller.user;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import pers.xiaojun.boot.common.pojo.CommonResult;
import pers.xiaojun.boot.module.system.controller.user.vo.profile.UserProfileRespVO;
import pers.xiaojun.boot.module.system.controller.user.vo.profile.UserProfileUpdateReqVO;
import pers.xiaojun.boot.module.system.service.user.UserProfileService;
import pers.xiaojun.boot.security.util.SecurityUtils;
import pers.xiaojun.boot.web.core.annotation.AdminApi;

/**
 * 用户资料控制层
 *
 * @author xiaojun
 * @since 2025-11-12
 */
@Tag(name = "用户资料")
@AdminApi
@RestController
@RequestMapping("/system/user/profile")
@RequiredArgsConstructor
public class UserProfileController {

    private final UserProfileService userProfileService;

    @GetMapping
    @Operation(summary = "获取用户资料")
    public CommonResult<UserProfileRespVO> gteUserProfile() {
        return CommonResult.success(userProfileService.getUserProfile(SecurityUtils.getUserId()));
    }

    @PutMapping()
    @Operation(summary = "更新用户资料")
    public CommonResult<?> updateUserProfile(@Valid @RequestBody UserProfileUpdateReqVO updateVO) {
        userProfileService.updateUserProfile(SecurityUtils.getUserId(), updateVO);
        return CommonResult.success();
    }

}
